package com.google.code.sip.ucenter.ws;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlType;

import com.google.code.sip.ucenter.ws.dto.*;

@XmlType(propOrder = { "datas" })
@XmlAccessorType(XmlAccessType.NONE)
public class WSResponseData<T> {
	@XmlMixed
	@XmlElementRefs( {
			@XmlElementRef(name = "page", type = PageDto.class),
			@XmlElementRef(name = "user", type = UserDto.class),
			@XmlElementRef(name = "userProfile", type = UserProfileDto.class),
			@XmlElementRef(name = "userCustomProfile", type = UserCustomProfileDto.class),
			@XmlElementRef(name = "userEvent", type = UserEventDto.class),
			@XmlElementRef(name = "application", type = ApplicationDto.class),
			@XmlElementRef(name = "credit", type = CreditDto.class),
			@XmlElementRef(name = "creditType", type = CreditTypeDto.class),
			@XmlElementRef(name = "creditRule", type = CreditRuleDto.class),
			@XmlElementRef(name = "creditRuleLog", type = CreditRuleLogDto.class),
			@XmlElementRef(name = "creditLog", type = CreditLogDto.class),
			@XmlElementRef(name = "friend", type = FriendDto.class),
			@XmlElementRef(name = "friendGroup", type = FriendGroupDto.class),
			@XmlElementRef(name = "huoshowAccount", type = HuoshowAccountDto.class),
			@XmlElementRef(name = "huoshowAccountLog", type = HuoshowAccountLogDto.class),
			@XmlElementRef(name = "notification", type = NotificationDto.class),
			@XmlElementRef(name = "setting", type = SettingDto.class) })
	private List<T> datas = new ArrayList<T>();

	public WSResponseData() {
	}

	public WSResponseData(List<T> datas) {
		setResult(datas);
	}

	public List<T> getResult() {
		return datas;
	}

	public void setResult(List<T> datas) {
		this.datas = datas;
	}

	public void addResult(T result) {
		this.datas.add(result);
	}

	public void addResult(Collection<T> result) {
		this.datas.addAll(result);
	}
}
